package edu.fafu.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import edu.fafu.dao.ILoginDao;
import edu.fafu.dao.IAnswerDao;
import edu.fafu.dao.IQuestionDao;
import edu.fafu.entity.Admin;
import edu.fafu.entity.Answer;
import edu.fafu.entity.Question;
import edu.fafu.service.ILoginService;
import edu.fafu.service.IAnswerService;
import edu.fafu.util.PageBean;
@Service("answerService")
public class AnswerService implements IAnswerService{
	@Resource(name="answerDao")
	private IAnswerDao answerDao;
	
	@Resource(name="questionDao")
	private IQuestionDao questionDao;

	@Transactional
	@Override
	public void addAnswer(Answer a,Question question) {
		a.setQuestionId(question);
		answerDao.addAnswer(a);
	}

	@Transactional
	@Override
	public PageBean queryAnswerByUser(int id, PageBean pb) {
		return answerDao.queryAnswerByUser(id,pb);
	}
	@Transactional
	@Override
	public void updateAnswer(Answer answer) {
		answer.setLikeNum(answer.getLikeNum()+1);
		answerDao.updateAnswer(answer);
		
	}
	@Transactional
	@Override
	public Answer queryAnswerOneById(int id) {
		return answerDao.queryAnswerOneById(id);
	}


	
	
}
